
package com.turing.post.webservice.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;


import com.turing.post.datatranferpmbs.util.SortInfoTranferBusiness;
import com.turing.post.util.PCPSApplicationException;

public class SortDataTset implements Runnable {

	public static void main(String[] args) throws InterruptedException {
		SortDataTset test = new SortDataTset();
		Thread thread = new Thread(test);
		System.out.println("开始线程");
		thread.start();

	}

	public SortDataTset() {
	}

	@SuppressWarnings("unchecked")
	@Override
	public void run() {
		// 用户登录成功信息检测
		Context ctx = null;
		// 根据客户端传来的名字查找相应的实现EJB
		SortInfoTranferBusiness dao = null;
		String name = "datatranferpmbs.impl.SortInfoTranferBusinessImpl" + "#"
				+ SortInfoTranferBusiness.class.getName();

		Hashtable env = new Hashtable();
		env.put(InitialContext.INITIAL_CONTEXT_FACTORY,
				"weblogic.jndi.WLInitialContextFactory");
		env.put(InitialContext.PROVIDER_URL, "t3://192.168.1.106:7001");

		try {
			ctx = new InitialContext(env);
		} catch (NamingException e1) {
			e1.printStackTrace();
		}

		try {
			System.out.println("初始化dao");
			dao = (SortInfoTranferBusiness) ctx.lookup(name);
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
		
		
		 SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		
		
		try{
			 Date date1=formatter.parse("2009-12-23");
			 System.out.println("总天数=="+date1.toGMTString());
			 int daycount = dao.getdaycount();
			 System.out.println("总天数=="+daycount);
			System.out.println(date1.toGMTString());
			System.out.println("hello");
			//dao.transferPMBSSortInfo(date1);
			System.out.println("hello1");
			int i = 1;
			while (i < daycount) {
				
				Date date = dao.getSortTranferDate();
				System.out.println("开始处理=="+date.toString());
				dao.transferPMBSSortInfo(date,"");
				i++;
			}
		
		}catch (PCPSApplicationException ep)
		{
			System.out.println("ep"+ep.getMessage());
		}
		catch (Exception e) {
			System.out.println("009"+e.getMessage());
			
		}

	}

}
